<template>
  <div class="list-item" :class="{'warn-active': rightText}">
    <div class="item-content" :style="{'height': height + 'rem'}" :class="{'center': height != 2.5}">
      <div class="left-box">
        <span :class="{'star': mustFill}">{{leftText}}</span>
        <div v-if="formatshow && upWarnShow" class="up-warn">
          <span class="error"></span>
          <span>未上传</span>
        </div>
      </div>
      <div class="middle-box" :style="{width: rightDom ? '20%' : '40%'}">
        <slot name="middledom"></slot>
      </div>
      <div class="right-box" :style="{width: rightDom ? '50%' : '30%'}">
        <span class="error" v-show="rightText">!</span>
        <span v-show="rightText">{{rightText}}</span>
        <slot name="rightdom" class="right-text"></slot>
      </div>
    </div>
    <div class="format-box" v-if="formatshow">
      <div>
        <p>（上传为JPG、PNG、GIF格式，大小在5M以内）</p>
      </div>
      <div class="see" v-if="templateShow" @click="showTemplate">
        <span class="see-icon"></span>
        <span>模板</span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    leftText: {
      type: String,
      default: ''
    },
    rightText: {
      type: String,
      default: ''
    },
    height: {
      type: Number,
      default: 0.9
    },
    formatshow: {
      type: Boolean,
      default: false
    },
    upWarnShow: {
      type: Boolean,
      default: false
    },
    imgType: {
      type: String,
      default: ''
    },
    mustFill: {
      type: Boolean,
      default: true
    },
    templateShow: {
      type: Boolean,
      default: true
    },
    rightDom: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
    }
  },
  methods: {
    showTemplate() {
      this.$emit('onSwitchShow', true, this.imgType)
    }
  }
}
</script>
<style lang='scss' scoped>
.list-item {
  width: 100%;
  // margin-bottom: 0.3rem;
  border-bottom: 1px solid#f2f4f5;
  .item-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    &.center {
      align-items: center;
    }
    .left-box {
      width: 30%;
      font-size: 0.28rem;
      color: rgba(102, 102, 102, 1);
      .star {
        &:after {
          content: "*";
          color: #fd4d4d;
          vertical-align: top;
        }
      }
      .up-warn {
        margin-top: 0.26rem;
        font-size: 0.24rem;
        font-weight: 500;
        color: rgba(255, 49, 49, 1);
        line-height: 0.3rem;
      }
    }
    .middle-box {
      span {
        font-size: 0.32rem;
        color: rgba(51, 51, 51, 1);
        line-height: 0.3rem;
      }
      input {
        width: 100%;
        line-height: 0.9rem;
        font-size: 0.24rem;
        line-height: 0.3rem;
        color: #333333;
      }
    }
    .right-box {
      text-align: right;
      position: relative;
      span {
        font-size: 0.24rem;
        line-height: 0.3rem;
        color: rgba(255, 49, 49, 1);
        margin-right: 0.06rem;
      }
      .tap-text {
        color: rgba(115, 158, 251, 1);
        position: absolute;
        bottom: 0.1rem;
        left: 0;
        right: 0;
      }
      img {
        width: 1.6rem;
        height: 0.68rem;
      }
    }
    .error {
      display: inline-block;
      vertical-align: middle;
      width: 0.26rem;
      height: 0.26rem;
      line-height: 0.26rem;
      background: #ff3131;
      border-radius: 50%;
      text-align: center;
      font-size: 0.24rem;
      color: #fff !important;
      margin-right: 0.04rem;
    }
  }
  .format-box {
    display: flex;
    justify-content: space-between;
    padding: 0.24rem 0;
    p {
      font-size: 0.24rem;
      color: rgba(189, 189, 189, 1);
      line-height: 0.34rem;
    }
    .see {
      cursor: pointer;
      .see-icon {
        display: inline-block;
        vertical-align: middle;
        margin-right: 0.14rem;
        width: 0.26rem;
        height: 0.26rem;
        background: url(../../../assets/img/eye-icon.png) center no-repeat;
        background-size: cover;
      }
      span {
        font-size: 0.24rem;
        font-weight: bold;
        color: rgba(115, 158, 251, 1);
        line-height: 0.3rem;
      }
    }
  }
}
.warn-active {
  border-color: rgba(255, 49, 49, 1);
}
</style>
